package gui.dialog;

/**
 *	The <code>ResourceObservable</code> class observes the state of
 *	a resource type. It notifies its observers whenever the value
 *	decreases. This class is used to observe the payment process
 *	and to react appropriately to any payments.
 *
 *	@author Grzegorz Kobiela
 *	@version 1.0 2008/4/26
 */
public final class ResourceObservable
extends java.util.Observable
{
	/** The value to observe. */
	private int value = 0;

	/**
	 *	Creates a new <code>ResourceObservable</code> instance
	 *	with the given value to observe.
	 *	@param value the value
	 */
	public ResourceObservable(int value) {
		this.value = value;
	}

	/**
	 *	Decreases the value by one and notifies its observers
	 *	of this change.
	 */
	public void decrease() {
		setChanged();
		notifyObservers(--value);
	}

	/**
	 *	Returns the value.
	 *	@return the value
	 */
	public int getValue() {
		return value;
	}
}